package com.springboot_intr2.controller;

import com.github.pagehelper.PageInfo;
import com.springboot_intr2.pojo.Dept;
import com.springboot_intr2.service.DeptService;
import com.springboot_intr2.pojo.Dept;
import com.springboot_intr2.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/dept")
public class DeptController {
    @Autowired
    private DeptService ds;

    @GetMapping("/all")
    public List<Dept> getAll(){
        return ds.getAll();
    }

    @GetMapping("/one/{deptno}")
    public Dept getOne1(@PathVariable("deptno") Integer deptno){
        return ds.getOne(deptno);
    }

    @GetMapping("/one")
    public Dept getOne2(Integer deptno){
        return ds.getOne(deptno);
    }

    @PostMapping("/save1")
    public int save1(Dept dept){
        return ds.save(dept);
    }

    @PostMapping("/save2")
    public int save2(@RequestBody Dept dept){
        return ds.save(dept);
    }

    @GetMapping("/bypage/{pageno}")
    public PageInfo<Dept> byPage(@PathVariable("pageno")Integer pno){
        return ds.bypage(pno);
    }




}
